package com.kaifamiao.thread.d0927;

import java.time.LocalTime;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class Demo05 {

    public static void main(String[] args) {
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(3);

//        for (int i = 0; i < 10; i++) {
//            int number = i;
//            scheduledExecutorService.schedule(() -> {
//                System.out.println("当前时间:" + LocalTime.now() + ", 线程: " + Thread.currentThread().getName() + ", 序号：" + number);
//                try {
//                    Thread.sleep(1000);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//            }, 1, TimeUnit.SECONDS);
//        }

        scheduledExecutorService.scheduleAtFixedRate(() -> System.out.println("1111"), 0, 2, TimeUnit.SECONDS);
    }
}
